package com.csnf.service.impl;

import com.csnf.mapper.GoodsMapper;
import com.csnf.service.GoodsService;
import csnf.com.entity.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    GoodsMapper goodsMapper;
    @Override
    public int insert(Goods record) {

        int result = goodsMapper.insert(record);
        record.setGId(result);
        if (result > 0){
            return goodsMapper.insertid(record);
        }else {
            return 0;
        }

    }



    @Override
    public ArrayList<Goods> selectAll(@RequestParam(required = false) Integer id) {
        return goodsMapper.selectAll(id);

    }

    @Override
    public int updateSaleStatus(Goods record) {
        return goodsMapper.updateSaleStatus(record);
    }
}
